package com.example.demo.dao;

import com.example.demo.domain.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.support.SimpleJpaRepository;
import org.springframework.stereotype.Repository;

import javax.persistence.EntityManager;
import java.io.Serializable;
import java.util.List;

/**
 * Created by gf on 2018/10/19.
 */
@Repository
public interface StudentRepository extends JpaRepository<Student, String> {

    @Query(value = "SELECT id,age,`NAME` FROM student WHERE 1 = 1 AND age = ?1",nativeQuery = true)
    List<Student> findByAge(Integer age);

    @Query(value = "SELECT stu.id,stu.name,stu.age FROM student stu WHERE 1 = 1",nativeQuery = true)
    List<Student> findAll() ;

}
